/*
* Copyright (C) 2020 ~ 2024 chaigec All Rights Reserved.
*
* Author:     chaigec <chaigec@163.com>
* Maintainer: chaigec <chaigec@163.com>

 * Use of this source code is governed by MIT license that can be found in the
 * LICENSE file in the root of the source tree. All contributing project authors
 * may be found in the AUTHORS file in the root of the source tree.
*/

#include "MkEvent/MkEventPool.h"
#include "MkEvent/MkEvent.h"
#include <gtest/gtest.h>

TEST(MkEventPool, EventPoolTest)
{
    CMkEventPool EventPool;
    Uint32 ErrorCode = EventPool.Start();
    EXPECT_EQ(ErrorCode, NoneError);

    EventPool.GetFreeEvent()->AddPipTask([]() {});
    EventPool.GetFreeEvent()->AddPipTask([]() {},TRUE);
    BOOL bRun = EventPool.IsRun();
    EXPECT_EQ(TRUE, bRun);
    ErrorCode = EventPool.Stop();
    EXPECT_EQ(ErrorCode, NoneError);
}

TEST(MkEventPool, EventPoolTest1)
{
    CMkEventPool EventPool;
    Uint32 ErrorCode = EventPool.Start(1);
    EXPECT_EQ(ErrorCode, NoneError);
    MkVector<CMkEvent*> VecEvent = EventPool.GetVecEvent();
    EXPECT_EQ(1, VecEvent.size());
    ErrorCode = EventPool.Stop();
    EXPECT_EQ(ErrorCode, NoneError);
}